<!DOCTYPE HTML>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/gc.js"></script>
<script>
description("Test GCing of WorkerGlobalScope supplementable");
window.jsTestIsAsync = true;
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

// Test that garbage collection of 'supplements' that extend the
// WorkerGlobalScope object is well behaved.
var worker = new Worker('../resources/worker-common.js');
var count = 0;

function ping()
{
    worker.postMessage("eval gc(); self.performance && self.performance.now()");
}
worker.onmessage = function (e) {
    if (count++ > 4)
        finishJSTest();
    else
        ping();
    gc();
}
ping();
</script>
